﻿using UnityEngine;
using System.Collections;

public class spintext : MonoBehaviour {

	public float currentRotateSpeed = 30f;
	public float speedChangeRate = 2f;
	public float minSpeed = 20f;
	public float speedCap = 400f;
	bool speedUp = true;

	public ParticleSystem partSys;

	// Update is called once per frame
	void Update () {
	
		transform.Rotate(0f,currentRotateSpeed*Time.deltaTime,0f);

		if (speedUp){
			currentRotateSpeed += speedChangeRate;
			if (currentRotateSpeed > speedCap){
				speedUp = false;
			}
		} else {
			currentRotateSpeed -= speedChangeRate;
			if (currentRotateSpeed < minSpeed){
				speedUp = true;
			}
		}

		if (currentRotateSpeed > 200f){
			partSys.Emit(200);
		}

	}
}
